import { getListApi } from "@/api/configCenter/warehouseCode";
import { getListApi as getAllCountryApi } from "@/api/configCenter/countryRegion";
import { getTreeChannelApi } from "@/api/configCenter/warehouseEntryChannel";

import { reactive } from "vue";

export const searchItemList: Array<SuperSearch.SearchItem> = [
  {
    type: "input",
    label: "运单号",
    keyName: "waybillNumList",
    placeholder: "支持批量(空格/逗号隔开)"
  },
  {
    type: "input",
    label: "FBA单号",
    keyName: "fbaNumberList",
    placeholder: "单个模糊查询"
  },
  {
    type: "input",
    label: "转单号",
    keyName: "transferOrderNumberList",
    placeholder: "支持批量(空格/逗号隔开)"
  },
  // {
  //   type: "input",
  //   label: "目的地",
  //   keyName: "countryRegionName"
  // },
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "目的地",
    keyName: "countryRegionName",
    optionsRequest: getAllCountryApi,
    optReqParams: { status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data.records || [];
      }
    },
    optConfig: {
      label: "region",
      value: "region"
    },
    options: []
  }),
  {
    type: "daterange",
    label: "下单时间",
    keyName: "createdTime"
  },
  // {
  //   type: "input",
  //   label: "渠道",
  //   keyName: "channelName"
  // },
  reactive<SuperSearch.SearchItem>({
    type: "cascader",
    label: "渠道",
    keyName: "channelId",
    optionsRequest: getTreeChannelApi,
    optReqParams: {},
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data || [];
      }
    },
    optConfig: {
      label: "label",
      value: "value",
      children: "children"
    },
    options: []
  }),
  reactive<SuperSearch.SearchItem>({
    type: "select",
    label: "仓库代码",
    keyName: "warehouseCode",
    optionsRequest: getListApi,
    optReqParams: { status: 1, pageNum: 1, pageSize: 9999999, total: 0 },
    optReqCb: (res: Base.GeneraDataType, row: SuperSearch.SearchItem) => {
      const { code, data } = res;
      if (code === 200) {
        row.options = data.records || [];
      }
    },
    optConfig: {
      label: "warehouseCode",
      value: "warehouseCode"
    },
    options: []
  }),
  {
    type: "input",
    label: "备注",
    keyName: "remark"
  }
];

export const tableColumnMap: Base.GeneraDataType<Array<SuperTable.TableCoulmnItem | SuperTable.NestTableColumnItem>> = {
  "-1": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "waybillNum",
      title: "运单号",
      minWidth: "160",
      renderSlot: "waybillNum"
    },
    {
      field: "fbaNumber",
      title: "FBA号",
      minWidth: "140"
    },
    {
      field: "transferOrderNumber",
      title: "转单号",
      minWidth: "150"
    },
    {
      field: "settlementWeight",
      title: "结算重",
      minWidth: "90"
    },
    {
      field: "mergeNo",
      title: "合并报关号",
      minWidth: "90"
    },
    {
      field: "countryRegionName",
      title: "目的地",
      minWidth: "90"
    },
    {
      field: "channelName",
      title: "渠道",
      minWidth: "140"
    },
    // {
    //   field: "agentChannelName",
    //   title: "代理渠道",
    //   minWidth: "140"
    // },
    {
      field: "itemNumber",
      title: "件数",
      minWidth: "80"
    },
    {
      field: "materialQualityName",
      title: "材质",
      minWidth: "120"
    },
    {
      field: "productName",
      title: "品名",
      minWidth: "120"
    },
    {
      field: "depositTime",
      title: "入仓时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "tracksStatus",
      title: "最新轨迹",
      minWidth: "160"
    },
    {
      field: "locusUpdateTime",
      title: "轨迹更新时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "createTime",
      title: "下单时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "createName",
      title: "下单人",
      minWidth: "90"
    },
    {
      field: "remark",
      title: "客户备注",
      minWidth: "90"
    }
  ],
  "1": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "fbaNumber",
      title: "FBA单号",
      minWidth: "140"
    },
    {
      field: "waybillNum",
      title: "运单号",
      minWidth: "160",
      renderSlot: "waybillNum"
    },
    {
      field: "transferOrderNumber",
      title: "转单号",
      minWidth: "150"
    },
    {
      field: "settlementWeight",
      title: "结算重",
      minWidth: "90"
    },
    {
      field: "mergeNo",
      title: "合并报关号",
      minWidth: "90"
    },
    {
      field: "countryRegionName",
      title: "目的地",
      minWidth: "90"
    },
    {
      field: "warehouseCode",
      title: "仓库代码",
      minWidth: "100"
    },
    {
      field: "channelName",
      title: "渠道",
      minWidth: "140"
    },
    // {
    //   field: "agentChannelName",
    //   title: "代理渠道",
    //   minWidth: "140"
    // },
    {
      field: "itemNumber",
      title: "件数",
      minWidth: "80"
    },
    {
      field: "materialQualityName",
      title: "材质",
      minWidth: "120"
    },
    {
      field: "productName",
      title: "品名",
      minWidth: "120"
    },
    {
      field: "receivableFeePrice",
      title: "应付费用",
      minWidth: "90"
    },
    {
      field: "depositTime",
      title: "入仓时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "createTime",
      title: "下单时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "createName",
      title: "下单人",
      minWidth: "90"
    },
    {
      field: "remark",
      title: "客户备注",
      minWidth: "90"
    }
  ],
  "5": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "fbaNumber",
      title: "FBA单号",
      minWidth: "140"
    },
    {
      field: "waybillNum",
      title: "运单号",
      minWidth: "160",
      renderSlot: "waybillNum"
    },
    {
      field: "countryRegionName",
      title: "目的地",
      minWidth: "90"
    },
    {
      field: "transferOrderNumber",
      title: "转单号",
      minWidth: "150"
    },
    {
      field: "settlementWeight",
      title: "结算重",
      minWidth: "90"
    },
    {
      field: "mergeNo",
      title: "合并报关号",
      minWidth: "90"
    },
    {
      field: "warehouseCode",
      title: "仓库代码",
      minWidth: "100"
    },
    {
      field: "channelName",
      title: "渠道",
      minWidth: "140"
    },
    // {
    //   field: "agentChannelName",
    //   title: "代理渠道",
    //   minWidth: "140"
    // },
    {
      field: "itemNumber",
      title: "件数",
      minWidth: "80"
    },
    {
      field: "actualWeight",
      title: "重量",
      minWidth: "80"
    },
    {
      field: "materialQualityName",
      title: "材质",
      minWidth: "120"
    },
    {
      field: "productName",
      title: "品名",
      minWidth: "120"
    },
    {
      field: "receivableFeePrice",
      title: "应付费用",
      minWidth: "90"
    },
    {
      field: "depositTime",
      title: "入仓时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "courierCompanies",
      title: "快递公司",
      minWidth: "90"
    },
    {
      field: "tracksStatus",
      title: "最新轨迹",
      minWidth: "160"
    },
    {
      field: "locusUpdateTime",
      title: "轨迹更新时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "createTime",
      title: "下单时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "childNumber",
      title: "子单号",
      minWidth: "120"
    },
    {
      field: "createName",
      title: "下单人",
      minWidth: "90"
    },
    {
      field: "remark",
      title: "客户备注",
      minWidth: "90"
    }
  ],
  "8": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "fbaNumber",
      title: "FBA单号",
      minWidth: "140"
    },
    {
      field: "waybillNum",
      title: "运单号",
      minWidth: "160",
      renderSlot: "waybillNum"
    },
    {
      field: "countryRegionName",
      title: "目的地",
      minWidth: "90"
    },
    {
      field: "transferOrderNumber",
      title: "转单号",
      minWidth: "150"
    },
    {
      field: "settlementWeight",
      title: "结算重",
      minWidth: "90"
    },
    {
      field: "mergeNo",
      title: "合并报关号",
      minWidth: "90"
    },
    {
      field: "warehouseCode",
      title: "仓库代码",
      minWidth: "100"
    },
    {
      field: "channelName",
      title: "渠道",
      minWidth: "140"
    },
    // {
    //   field: "agentChannelName",
    //   title: "代理渠道",
    //   minWidth: "140"
    // },
    {
      field: "itemNumber",
      title: "件数",
      minWidth: "80"
    },
    {
      field: "actualWeight",
      title: "重量",
      minWidth: "80"
    },
    {
      field: "materialQualityName",
      title: "材质",
      minWidth: "120"
    },
    {
      field: "productName",
      title: "品名",
      minWidth: "120"
    },
    {
      field: "receivableFeePrice",
      title: "应付费用",
      minWidth: "90"
    },
    {
      field: "depositTime",
      title: "入仓时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "courierCompanies",
      title: "快递公司",
      minWidth: "90"
    },
    {
      field: "tracksStatus",
      title: "最新轨迹",
      minWidth: "160"
    },
    {
      field: "locusUpdateTime",
      title: "轨迹更新时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "createTime",
      title: "下单时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "childNumber",
      title: "子单号",
      minWidth: "120"
    },
    {
      field: "createName",
      title: "下单人",
      minWidth: "90"
    },
    {
      field: "remark",
      title: "客户备注",
      minWidth: "90"
    }
  ],
  "9": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "fbaNumber",
      title: "FBA单号",
      minWidth: "140"
    },
    {
      field: "waybillNum",
      title: "运单号",
      minWidth: "160",
      renderSlot: "waybillNum"
    },
    {
      field: "countryRegionName",
      title: "目的地",
      minWidth: "90"
    },
    {
      field: "transferOrderNumber",
      title: "转单号",
      minWidth: "150"
    },
    {
      field: "settlementWeight",
      title: "结算重",
      minWidth: "90"
    },
    {
      field: "mergeNo",
      title: "合并报关号",
      minWidth: "90"
    },
    {
      field: "warehouseCode",
      title: "仓库代码",
      minWidth: "100"
    },
    {
      field: "channelName",
      title: "渠道",
      minWidth: "140"
    },
    // {
    //   field: "agentChannelName",
    //   title: "代理渠道",
    //   minWidth: "140"
    // },
    {
      field: "itemNumber",
      title: "件数",
      minWidth: "80"
    },
    {
      field: "actualWeight",
      title: "重量",
      minWidth: "80"
    },
    {
      field: "materialQualityName",
      title: "材质",
      minWidth: "120"
    },
    {
      field: "productName",
      title: "品名",
      minWidth: "120"
    },
    {
      field: "receivableFeePrice",
      title: "应付费用",
      minWidth: "90"
    },
    {
      field: "depositTime",
      title: "入仓时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "courierCompanies",
      title: "快递公司",
      minWidth: "90"
    },
    {
      field: "tracksStatus",
      title: "最新轨迹",
      minWidth: "160"
    },
    {
      field: "locusUpdateTime",
      title: "轨迹更新时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "createTime",
      title: "下单时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "childNumber",
      title: "子单号",
      minWidth: "120"
    },
    {
      field: "createName",
      title: "下单人",
      minWidth: "90"
    },
    {
      field: "remark",
      title: "客户备注",
      minWidth: "90"
    }
  ],
  "0": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "fbaNumber",
      title: "FBA单号",
      minWidth: "140"
    },
    {
      field: "waybillNum",
      title: "运单号",
      minWidth: "160",
      renderSlot: "waybillNum"
    },
    {
      field: "countryRegionName",
      title: "目的地",
      minWidth: "90"
    },
    {
      field: "transferOrderNumber",
      title: "转单号",
      minWidth: "150"
    },
    {
      field: "settlementWeight",
      title: "结算重",
      minWidth: "90"
    },
    {
      field: "mergeNo",
      title: "合并报关号",
      minWidth: "90"
    },
    {
      field: "warehouseCode",
      title: "仓库代码",
      minWidth: "100"
    },
    {
      field: "channelName",
      title: "渠道",
      minWidth: "140"
    },
    // {
    //   field: "agentChannelName",
    //   title: "代理渠道",
    //   minWidth: "140"
    // },
    {
      field: "itemNumber",
      title: "件数",
      minWidth: "80"
    },
    {
      field: "actualWeight",
      title: "重量",
      minWidth: "80"
    },
    {
      field: "materialQualityName",
      title: "材质",
      minWidth: "120"
    },
    {
      field: "productName",
      title: "品名",
      minWidth: "120"
    },
    {
      field: "createTime",
      title: "下单时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "childNumber",
      title: "子单号",
      minWidth: "120"
    },
    {
      field: "createName",
      title: "下单人",
      minWidth: "90"
    },
    {
      field: "remark",
      title: "客户备注",
      minWidth: "90"
    }
  ],
  "-2": [
    {
      type: "checkbox",
      field: "checkbox",
      minWidth: "50"
    },
    {
      field: "fbaNumber",
      title: "FBA单号",
      minWidth: "140"
    },
    {
      field: "waybillNum",
      title: "运单号",
      minWidth: "160",
      renderSlot: "waybillNum"
    },
    {
      field: "countryRegionName",
      title: "目的地",
      minWidth: "90"
    },
    {
      field: "transferOrderNumber",
      title: "转单号",
      minWidth: "150"
    },
    {
      field: "settlementWeight",
      title: "结算重",
      minWidth: "90"
    },
    {
      field: "mergeNo",
      title: "合并报关号",
      minWidth: "90"
    },
    {
      field: "warehouseCode",
      title: "仓库代码",
      minWidth: "100"
    },
    {
      field: "channelName",
      title: "渠道",
      minWidth: "140"
    },
    // {
    //   field: "agentChannelName",
    //   title: "代理渠道",
    //   minWidth: "140"
    // },
    {
      field: "itemNumber",
      title: "件数",
      minWidth: "80"
    },
    {
      field: "actualWeight",
      title: "重量",
      minWidth: "80"
    },
    {
      field: "materialQualityName",
      title: "材质",
      minWidth: "120"
    },
    {
      field: "productName",
      title: "品名",
      minWidth: "120"
    },
    {
      field: "receivableFeePrice",
      title: "应付费用",
      minWidth: "90"
    },
    {
      field: "depositTime",
      title: "入仓时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "courierCompanies",
      title: "快递公司",
      minWidth: "90"
    },
    {
      field: "tracksStatus",
      title: "最新轨迹",
      minWidth: "160"
    },
    {
      field: "locusUpdateTime",
      title: "轨迹更新时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "createTime",
      title: "下单时间",
      minWidth: "135",
      formatter: "formatDate"
    },
    {
      field: "childNumber",
      title: "子单号",
      minWidth: "120"
    },
    {
      field: "createName",
      title: "下单人",
      minWidth: "80"
    },
    {
      field: "remark",
      title: "客户备注",
      minWidth: "90"
    }
  ]
};
